{include file="public/header" /}

<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">时间范围</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="time" class="layui-input" id="test6" placeholder=" - ">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
            </div>

            <!--<div class="layui-card-body">-->
            <!--<div style="padding-bottom: 10px;">-->
            <!--<button class="layui-btn layuiadmin-btn-list" data-type="batchdel">删除</button>-->
            <!--<button class="layui-btn layuiadmin-btn-list" data-type="add">添加</button>-->
            <!--</div>-->
            <!--</div>-->
        </div>

        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <!--<div class="layui-card-header">逾期统计</div>-->
                    <div class="layui-card-body">
                        <table class="layui-hide" id="test-table-checkbox" lay-filter="test-table-checkbox"></table>

                        <!--<script type="text/html" id="store_pid">-->
                        <!--<img src="{{d.logo}}" style="display: inline-block; width: 100%; height: 100%;" alt="aaaaaaaaaa">-->
                        <!--</script>-->

                        <script type="text/html" id="table-content-list">
                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="channel">渠道</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

{include file="public/footer" /}

<script>
    layui.use(['index', 'table','form','laydate'], function(){
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;

        //日期主题
        laydate.render({
            elem: '#test6'
            ,range: true
            ,theme: 'molv'
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('test-table-checkbox', {
                where:{
                    'name':field.name,
                    'time':field.time,
                }
            });
        });

        //定义表格基础参数
        table.render({
            elem: '#test-table-checkbox',
            url: "{:url('admin/sum/overdue')}",
            toolbar:true,
            defaultToolbar: ['filter', 'exports', 'print'],
            height: 'full-200',//最大高度
            even: true,
            cols: [[//标题栏

                {field: 'time', title: "<p style='text-align:center;'>日期</p>", width: 110, rowspan: 2,fixed: 'left'} //rowspan即纵向跨越的单元格数
                ,{field: 'yhNum', title: "<span lay-tips='今日到期应还订单数'>应还单数?</span>", width: 100, rowspan: 2}
                ,{field: 'yhNums', title: "<span lay-tips='今日到期已还订单数'>已还单数?</span>", width: 100, rowspan: 2}
                ,{field: 'yqNum', title: "<span lay-tips='今日逾期订单数'>逾期单数?</span>", width: 100, rowspan: 2}
                ,{field: 'yqYhNum', title: "<span lay-tips='今日逾期已还单数订单数'>逾期已还单数?</span>", width: 130, rowspan: 2}
                ,{field: 'yqHkLv', title: "<span lay-tips='逾期回款率 = (逾期已还单数/逾期单数)*100%'>逾期回款率?</span>", width: 110, rowspan: 2}

                ,{align: 'center1', title: "<span lay-tips='用户第一笔借款视为新客'><p style='text-align:center'>新客逾期?</p></span>", colspan: 3}
                ,{align: 'center1', title: "<span lay-tips='用户在已有一笔已完成订单基数上后续订单均属于老客订单'><p style='text-align:center'>老客逾期?</p></span>", colspan: 3}
                ,{align: 'center1', title: "<p style='text-align:center'>逾期1-3天</p>", colspan: 3}
                ,{align: 'center2', title: "<p style='text-align:center'>逾期4-7天</p>", colspan: 3}
                ,{align: 'center3', title: "<p style='text-align:center'>逾期8-15天</p>", colspan: 3}
                ,{align: 'center4', title: "<p style='text-align:center'>逾期15+</p>", colspan: 3}
                ,{fixed: 'right',title:'操作', width:160, align:'center', toolbar: '#table-content-list'}
            ], [
                {field: 'xkYqNum', title: '逾期单数', width: 100}
                ,{field: 'xkYhNum', title: '已还单数', width: 100}
                ,{field: 'xkHkLv', title: "<span lay-tips='回款率 = (已还单数/逾期单数)*100%'>回款率?</span>", width: 100}

                ,{field: 'lkYqNum', title: '逾期单数', width: 100}
                ,{field: 'lkYhNum', title: '已还单数', width: 100}
                ,{field: 'lkHkLv', title: "回款率", width: 100}

                ,{field: 'yq13Num', title: '逾期单数', width: 100}
                ,{field: 'yh13Num', title: '已还单数', width: 100}
                ,{field: 'yq13HkLv', title: "回款率", width: 100}

                ,{field: 'yq47Num', title: '逾期单数', width: 100}
                ,{field: 'yh47Num', title: '已还单数', width: 100}
                ,{field: 'yq47HkLv', title: "回款率", width: 100}

                ,{field: 'yq815Num', title: '逾期单数', width: 100}
                ,{field: 'yh815Num', title: '已还单数', width: 100}
                ,{field: 'yq845HkLv', title: "回款率", width: 100}

                ,{field: 'yq15Num', title: '逾期单数', width: 100}
                ,{field: 'yh15Num', title: '已还单数', width: 100}
                ,{field: 'yq15HkLv', title: "回款率", width: 100}
            ]],
            page: true
        });

        //监听工具栏
        table.on('tool(test-table-checkbox)', function(obj){
            if(obj.event === 'channel'){
                if(obj.data){
                    layer.open({
                        type: 2
                        ,title: ''
                        ,content: 'overdueChannel?time='+obj.data.time
                        ,maxmin: true
                        ,area:['90%','80%']
                        ,shadeClose:true,
                    });
                }else{
                    layer.msg('未查到渠道信息',{time:600});
                }
            }
        });
    });
</script>
